package com.swan.beans;

/**
 * UserInfo
 * keep login information
 * @author xyh
 * @param <T>
 * @date 20230426
 *
 */
public class UserInfo {
	private static UserInfo instance;

	private String userName;
	
	private int userId;

	private UserInfo(String userName,int userId) {
		this.userName = userName;
		this.userId=userId;
	}

	public static UserInfo getInstace(String userName,int userId) {
		if (instance == null) {
			instance = new UserInfo(userName,userId);
		}
		return instance;
	}
	
	public static UserInfo getLoginUser() {
		return instance;
	}

	public String getUserName() {
		return userName;
	}

	
	
	public int getUserId() {
		return userId;
	}

	public static void cleanUserSession() {
		instance=null;
	}

	@Override
	public String toString() {
		return "UserSession{" + 
	"userName='" + userName +
	"userId='" + userId +
	'\'' + '}';
	}
}
